<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>用户注册页面</title>
    <jsp:include page="../part/css/register.jsp" flush="true"/>
    <jsp:include page="../part/js/register.jsp" flush="true"/>
</head>
<body>

<form action="register" method="post" onsubmit="return handleSubmit()">
    <h2 class="title">欢迎来到学生管理注册页面</h2>
    <span class="form-item-label"> 用户名</span> <input class="form-item" type="text" name="username"
                                                        placeholder="请输入用户名">
    <span></span>
    <c:if test="${!empty register_result.errorMsg.username}">
        <span class="error-msg">${register_result.errorMsg.username}</span>
    </c:if>
    <c:if test="${empty register_result.errorMsg.username}">
        <span class="hidden">错误提示</span>
    </c:if>


    <span class="form-item-label">密码</span><input class="form-item" type="password" name="password"
                                                    placeholder="请输入密码">
    <span></span>
    <c:if test="${!empty register_result.errorMsg.password}">
        <span class="error-msg">${register_result.errorMsg.password}</span>
    </c:if>
    <c:if test="${empty register_result.errorMsg.password}">
        <span class="hidden">错误提示</span>
    </c:if>

    <span class="form-item-label">邮箱</span><input class="form-item" type="email" name="email"
                                                    placeholder="请输入邮箱">
    <span></span>
    <c:if test="${!empty register_result.errorMsg.email}">
        <span class="error-msg">${register_result.errorMsg.email}</span>
    </c:if>
    <c:if test="${empty register_result.errorMsg.email}">
        <span class="hidden">错误提示</span>
    </c:if>


    <span class="form-item-label">手机号</span><input class="form-item" type="text" name="mobile"
                                                      placeholder="请输入手机号">
    <span></span>
    <c:if test="${!empty register_result.errorMsg.mobile}">
        <span class="error-msg">${register_result.errorMsg.mobile}</span>
    </c:if>
    <c:if test="${empty register_result.errorMsg.mobile}">
        <span class="hidden">错误提示</span>
    </c:if>


    <span class="form-item-label">用户类型</span>
    <select class="form-item" name="type">
        <option value="1">普通用户</option>
        <option value="2">管理员</option>
    </select>
    <input class="form-btn" type="submit" value="注册">
    <input class="form-btn" type="reset" value="重置">
    <span class="to-login">已有账号?<a href="${pageContext.request.contextPath}/login.html"> 去登录</a></span>
    <input type="hidden" name="repeat_code" value="${repeat_code}">

</form>

<script type="text/javascript">

    function handleSubmit() {

        let loading = layer.showLoading("正在登陆请稍后", null, () => {

        })

        function login(success, error) {

            if (success) {
                success();
            }
            if (error) {
                error();
            }
        }

        let dotLen = 1;
        let interval = setInterval(function () {
            // 防止dotLen大于3
            if (dotLen > 3) {
                dotLen = 1;
            }

            // 根据dotLen生成 ... 优雅的方式
            let dots = "";
            for (let i = 0; i < dotLen; i++) {
                dots += ".";
            }
            loading.setMsg("正在登陆请稍后" + dots);
            dotLen++;

        }, 1000);


        return true;
    }
</script>
</body>
</html>
